import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:1 2 3 4 5 6 7 8 9
 * User: 东莞呵呵
 * Date:2022-03-26
 * Time:9:06
 */
public class TestDemo {
    public static void main(String[] args) {
        int []arr= new int[9];
        int left=0;
        int right=arr.length-2;
        int input=0;
        int mid=0;
        int index=0;
        int i=0;

        Scanner scanner=new Scanner(System.in);
        for(i=0;i<8;i++){
            arr[i]=scanner.nextInt();
        }
        input=scanner.nextInt();

        while(left<right){
            mid=(left+right)/2;
            if(input<arr[mid]){
                right=mid-1;
                index=right;
            }else if(input>arr[mid]){
                left=mid+1;
                index=left;
            }else{
                index=mid;
            }
        }
        for(int j=i;j>index;j--){
            arr[j]=arr[j-1];
        }
        arr[index]=input;
        System.out.println(Arrays.toString(arr));
    }
}
